#pragma once

#include <stdint.h>
#include <functional>
#include <memory>
#include "uv.h"
#include "event_async.h"
#include "event_record.h"


namespace rr {
namespace nio {

class EventLoop
{
public:
    using Sptr = std::shared_ptr<EventLoop>;
    using Var = EventLoop*;
    using PendingCallback = std::function<void()>;
public:
    EventLoop();
    ~EventLoop();

    int32_t Loop();
    void Quit();

    void RunInLoop(const PendingCallback& cb);

    uv_loop_t* GetLoop() {  return loop_; }
    EventRecorder::Sptr GetEventRecorder() { return event_recorder_; }

private:
    uv_loop_t* loop_;
    EventAsync::Sptr async_;
    EventRecorder::Sptr event_recorder_;
};


} //namespace 
} //namespace 
